Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-04-04 12:44:25 +0300
committerShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-04-06 17:46:58 +0300
commit914bef671f54c04a0d36d8e0f8c9830d6dea7b03 (patch)
tree46067eb41371f1b5a1cbc9a27444ecbc40c45043 /lib
parent27f981b2901098f894e587bbd96b09e2a0f0c404 (diff)
Move Ci::CronParser to Gitlab::Ci::CronParser
Diffstat (limited to 'lib')
-rw-r--r--lib/ci/cron_parser.rb36
-rw-r--r--lib/gitlab/ci/cron_parser.rb38
2 files changed, 38 insertions, 36 deletions
diff --git a/lib/ci/cron_parser.rb b/lib/ci/cron_parser.rb
deleted file mode 100644
index e0d589956a8..00000000000
--- a/lib/ci/cron_parser.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-module Ci
- class CronParser
- VALID_SYNTAX_SAMPLE_TIME_ZONE = 'UTC'.freeze
- VALID_SYNTAX_SAMPLE_CRON = '* * * * *'.freeze
-
- def initialize(cron, cron_time_zone = 'UTC')
- @cron = cron
- @cron_time_zone = cron_time_zone
- end
-
- def next_time_from(time)
- cron_line = try_parse_cron(@cron, @cron_time_zone)
- if cron_line.present?
- cron_line.next_time(time).in_time_zone(Time.zone)
- else
- nil
- end
- end
-
- def validation
- is_valid_cron = try_parse_cron(@cron, VALID_SYNTAX_SAMPLE_TIME_ZONE).present?
- is_valid_cron_time_zone = try_parse_cron(VALID_SYNTAX_SAMPLE_CRON, @cron_time_zone).present?
- return is_valid_cron, is_valid_cron_time_zone
- end
-
- private
-
- def try_parse_cron(cron, cron_time_zone)
- begin
- Rufus::Scheduler.parse("#{cron} #{cron_time_zone}")
- rescue
- nil
- end
- end
- end
-end
diff --git a/lib/gitlab/ci/cron_parser.rb b/lib/gitlab/ci/cron_parser.rb
new file mode 100644
index 00000000000..01f37142510
--- /dev/null
+++ b/lib/gitlab/ci/cron_parser.rb
@@ -0,0 +1,38 @@
+module Gitlab
+ module Ci
+ class CronParser
+ VALID_SYNTAX_SAMPLE_TIME_ZONE = 'UTC'.freeze
+ VALID_SYNTAX_SAMPLE_CRON = '* * * * *'.freeze
+
+ def initialize(cron, cron_time_zone = 'UTC')
+ @cron = cron
+ @cron_time_zone = cron_time_zone
+ end
+
+ def next_time_from(time)
+ cron_line = try_parse_cron(@cron, @cron_time_zone)
+ if cron_line.present?
+ cron_line.next_time(time).in_time_zone(Time.zone)
+ else
+ nil
+ end
+ end
+
+ def validation
+ is_valid_cron = try_parse_cron(@cron, VALID_SYNTAX_SAMPLE_TIME_ZONE).present?
+ is_valid_cron_time_zone = try_parse_cron(VALID_SYNTAX_SAMPLE_CRON, @cron_time_zone).present?
+ return is_valid_cron, is_valid_cron_time_zone
+ end
+
+ private
+
+ def try_parse_cron(cron, cron_time_zone)
+ begin
+ Rufus::Scheduler.parse("#{cron} #{cron_time_zone}")
+ rescue
+ nil
+ end
+ end
+ end
+ end
+end \ No newline at end of file