quandl_utility 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03eb516e16528dee425ec889bd77d73b0e0604d7
4
- data.tar.gz: ea667879527199ab7de88114e2738f6ead865e35
3
+ metadata.gz: a466e990945d2a0bf3399f68892f74302e5f875d
4
+ data.tar.gz: 459c92f7fa3b4c42ffa85bb6e6e86c664dea79e0
5
5
  SHA512:
6
- metadata.gz: e41e9bc4c3ce32b732e0ac767b27eda9df474bad28d6bd6fb1f88db366a2ff36548d264a096aeb3da8a88a12f91af25e5b270b32dfbcfaf079142eed704c0587
7
- data.tar.gz: 15119a4ad2fb787f720446983492e003688bc81c92055a126d426f8ca5de438bbdfd6efcfadb5dac8186142753ece40bd269ec1a0f73d9ace8ec9a5ebf3d1340
6
+ metadata.gz: e8bf4ba28e6f7005301c477ce9de48609e9982c82905f06e465c4149e0f528e9dba3e8ad14be36690fd94bea131a06349ff99aaccbd8089aff5f9cbe6fd76463
7
+ data.tar.gz: c0af7f2795d192767ba5fc6136274b4126d454e10ed37fe76a04d11cae3010d7ab0d0be0c952fb0b82357fd150292dedaa069a25ca768660f439ca0f94ff9d4b
@@ -7,6 +7,10 @@ AlignParameters:
7
7
  Exclude:
8
8
  - lib/quandl/utility/thor_tasks/*
9
9
  LineLength:
10
- Max: 100
10
+ Max: 150
11
11
  MethodLength:
12
- Max: 20
12
+ Max: 20
13
+ Documentation:
14
+ Enabled: false
15
+ Debugger:
16
+ Enabled: false
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
  gemspec
data/README.md CHANGED
@@ -21,7 +21,7 @@ Quandl::Utility Thor tasks are available in two ways:
21
21
  * Using the executable 'qutil'
22
22
 
23
23
  ```bash
24
- qutil notify slack '#general' 'ping!' -w 'WEBHOOK_URL'
24
+ qutil ci:notify_slack
25
25
  ```
26
26
 
27
27
  * Including in your Thorfile
@@ -31,7 +31,7 @@ require 'quandl/utility/thor_tasks'
31
31
 
32
32
  desc 'my_task'
33
33
  def my_task
34
- invoke 'qutil:slack:notify', ['#general', 'ping!']
34
+ invoke 'qutil:ci:notify_slack', ['#general', 'ping!']
35
35
  end
36
36
  ```
37
37
 
@@ -81,17 +81,3 @@ Notify slack of build status. Uses various tddium ENV variables to build a messa
81
81
  ```bash
82
82
  qutil ci notify_slack
83
83
  ```
84
-
85
- ### Notify
86
-
87
- Task for notifications. Currently supports sending messages to Slack.
88
-
89
- ```bash
90
- qutil notify help
91
- ```
92
-
93
- #### slack
94
-
95
- ```bash
96
- qutil notify slack MESSAGE #CHANNEL -w WEBHOOK_URL
97
- ```
data/Rakefile CHANGED
@@ -1,12 +1,12 @@
1
- require "bundler"
2
- require "rake"
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
1
+ require 'bundler'
2
+ require 'rake'
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
5
  require 'pry'
6
6
 
7
- task :default => :spec
7
+ task default: :spec
8
8
 
9
- desc "Run all specs"
9
+ desc 'Run all specs'
10
10
  RSpec::Core::RakeTask.new(:spec) do |task|
11
- task.pattern = "spec/**/*_spec.rb"
11
+ task.pattern = 'spec/**/*_spec.rb'
12
12
  end
data/Thorfile CHANGED
@@ -1,4 +1,4 @@
1
- $:.push File.expand_path('../lib', __FILE__)
1
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
2
2
 
3
3
  require 'bundler'
4
4
  require 'thor'
data/UPGRADE.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.2.2
2
+
3
+ * Replace notify thor task with Quandl::Slack
4
+ * Make Rubocop compliant
5
+
1
6
  ## 0.2.1
2
7
 
3
8
  * Add support for custom CI notification messages.
@@ -53,4 +58,4 @@
53
58
 
54
59
  ## 0.0.1
55
60
 
56
- * Version bump to 0.0.1
61
+ * Version bump to 0.0.1
data/bin/qutil CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
3
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
4
4
  require 'quandl/utility/cli'
5
5
  Quandl::Utility::CLI.start
@@ -1,6 +1,5 @@
1
1
  require 'thor'
2
2
  require 'quandl/utility/thor_tasks/lint'
3
- require 'quandl/utility/thor_tasks/notify'
4
3
  require 'quandl/utility/thor_tasks/ci'
5
4
 
6
5
  module Quandl
@@ -12,9 +11,6 @@ module Quandl
12
11
  desc 'lint', 'Linting subcommands'
13
12
  subcommand 'lint', Quandl::Utility::ThorTasks::Lint
14
13
 
15
- desc 'notify', 'Notification subcommands'
16
- subcommand 'notify', Quandl::Utility::ThorTasks::Notify
17
-
18
14
  desc 'ci', 'CI Server subcommands'
19
15
  subcommand 'ci', Quandl::Utility::ThorTasks::CI
20
16
  end
@@ -1,62 +1,58 @@
1
1
  module Quandl
2
- module Utility
3
- class Configuration
4
-
5
- class << self
6
-
7
- def define_attributes(*attribute_names)
8
- attribute_names.each do |key|
9
- define_attribute(key)
2
+ module Utility
3
+ class Configuration
4
+ class << self
5
+ def define_attributes(*attribute_names)
6
+ attribute_names.each do |key|
7
+ define_attribute(key)
8
+ end
9
+ end
10
+
11
+ def attributes
12
+ @attributes ||= []
13
+ end
14
+
15
+ protected
16
+
17
+ def define_attribute(key)
18
+ key = key.to_s
19
+ attributes << key unless attributes.include?(key)
20
+ define_method(key) { read_attribute(key) }
21
+ define_method("#{key}=") { |value| write_attribute(key, value) }
22
+ end
23
+ end
24
+
25
+ def initialize(object = {})
26
+ self.attributes = object
27
+ after_initialize
28
+ end
29
+
30
+ def after_initialize
31
+ end
32
+
33
+ def to_h
34
+ attributes
35
+ end
36
+
37
+ def attributes=(attrs)
38
+ attrs.each do |key, value|
39
+ send("#{key}=", value) if self.respond_to?("#{key}=")
40
+ end
41
+ end
42
+
43
+ def attributes
44
+ @attributes ||= {}
45
+ end
46
+
47
+ protected
48
+
49
+ def read_attribute(key)
50
+ attributes[key.to_s]
51
+ end
52
+
53
+ def write_attribute(key, value)
54
+ attributes[key.to_s] = value
10
55
  end
11
- end
12
-
13
- def attributes
14
- @attributes ||= []
15
- end
16
-
17
- protected
18
-
19
- def define_attribute(key)
20
- key = key.to_s
21
- attributes << key unless attributes.include?(key)
22
- define_method( key ){ read_attribute(key) }
23
- define_method( "#{key}=" ){ |value| write_attribute(key, value) }
24
- end
25
-
26
- end
27
-
28
- def initialize(object={})
29
- self.attributes = object
30
- after_initialize
31
- end
32
-
33
- def after_initialize
34
- end
35
-
36
- def to_h
37
- attributes
38
- end
39
-
40
- def attributes=(attrs)
41
- attrs.each do |key, value|
42
- self.send("#{key}=", value) if self.respond_to?("#{key}=")
43
56
  end
44
57
  end
45
-
46
- def attributes
47
- @attributes ||= {}
48
- end
49
-
50
- protected
51
-
52
- def read_attribute(key)
53
- attributes[key.to_s]
54
- end
55
-
56
- def write_attribute(key, value)
57
- attributes[key.to_s] = value
58
- end
59
-
60
- end
61
58
  end
62
- end
@@ -1,2 +1,2 @@
1
1
  require 'rake'
2
- require "quandl/utility"
2
+ require 'quandl/utility'
@@ -1,38 +1,35 @@
1
1
  module Quandl
2
- module Utility
3
- class Tasks
2
+ module Utility
3
+ class Tasks
4
+ class << self
5
+ attr_accessor :configuration
6
+ end
4
7
 
5
- class << self
6
- attr_accessor :configuration
7
- end
8
+ def self.configuration
9
+ @configuration ||= TaskConfig.new
10
+ end
8
11
 
9
- def self.configuration
10
- @configuration ||= TaskConfig.new
11
- end
12
+ def self.configure
13
+ yield(configuration)
14
+ load File.join(Quandl::Utility.root_path, 'tasks/utility.rake')
15
+ true
16
+ end
12
17
 
13
- def self.configure
14
- yield(configuration)
15
- load File.join( Quandl::Utility.root_path, 'tasks/utility.rake' )
16
- true
17
- end
18
+ class TaskConfig < Quandl::Utility::Configuration
19
+ define_attributes :name, :changelog_path, :changelog_matching, :version_path, :tag_prefix
18
20
 
19
- class TaskConfig < Quandl::Utility::Configuration
20
- define_attributes :name, :changelog_path, :changelog_matching, :version_path, :tag_prefix
21
-
22
- def version_with_prefix
23
- "#{tag_prefix}#{version}"
24
- end
25
-
26
- def tag_prefix
27
- read_attribute(:tag_prefix)
28
- end
29
-
30
- def version
31
- @version ||= File.exists?(version_path) ? File.read(version_path) : '0.0.0'
21
+ def version_with_prefix
22
+ "#{tag_prefix}#{version}"
23
+ end
24
+
25
+ def tag_prefix
26
+ read_attribute(:tag_prefix)
27
+ end
28
+
29
+ def version
30
+ @version ||= File.exist?(version_path) ? File.read(version_path) : '0.0.0'
31
+ end
32
+ end
32
33
  end
33
-
34
34
  end
35
-
36
- end
37
35
  end
38
- end
@@ -1,3 +1,2 @@
1
1
  require_relative 'thor_tasks/lint'
2
- require_relative 'thor_tasks/notify'
3
- require_relative 'thor_tasks/ci'
2
+ require_relative 'thor_tasks/ci'
@@ -1,4 +1,7 @@
1
1
  require 'thor'
2
+ require 'quandl/slack'
3
+
4
+ Quandl::Slack.generate_notifier('ci')
2
5
 
3
6
  module Quandl
4
7
  module Utility
@@ -10,9 +13,7 @@ module Quandl
10
13
  desc 'notify_slack', 'Notify Quandl of build status of CI'
11
14
  def notify_slack(message = nil)
12
15
  notification = message.nil? ? ci_build_message : "#{ci_build_message} - #{message}"
13
- invoke 'qutil:notify:slack',
14
- [notification, slack_channel],
15
- emoji: slack_emoji
16
+ Quandl::Slack::Ci.ping(notification, channel: slack_channel, icon_emoji: slack_emoji)
16
17
  end
17
18
 
18
19
  private
@@ -1,5 +1,5 @@
1
1
  module Quandl
2
2
  module Utility
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
  end
5
5
  end
@@ -1,33 +1,33 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "quandl/utility/version"
2
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
+ require 'quandl/utility/version'
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = "quandl_utility"
6
+ s.name = 'quandl_utility'
7
7
  s.version = Quandl::Utility::VERSION
8
- s.authors = ["Blake Hilscher"]
9
- s.email = ["dev@quandl.com"]
10
- s.homepage = "https://www.quandl.com"
11
- s.license = "MIT"
12
- s.summary = "Utility Tools"
13
- s.description = "Tools for making our lives easier."
8
+ s.authors = ['Blake Hilscher', 'Jason Byck', 'Najwa Azer']
9
+ s.email = ['dev@quandl.com']
10
+ s.homepage = 'https://www.quandl.com'
11
+ s.license = 'MIT'
12
+ s.summary = 'Utility Tools'
13
+ s.description = 'Tools for making our lives easier.'
14
14
 
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
- s.require_paths = ["lib", 'tasks']
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
18
+ s.require_paths = %w(lib tasks)
19
19
 
20
- s.add_runtime_dependency "activesupport", ">= 3.0.0"
21
- s.add_runtime_dependency "rake"
20
+ s.add_runtime_dependency 'activesupport', '>= 3.0.0'
21
+ s.add_runtime_dependency 'rake'
22
22
  s.add_runtime_dependency 'thor'
23
23
  s.add_runtime_dependency 'thor-foodcritic'
24
24
  s.add_runtime_dependency 'rubocop'
25
- s.add_runtime_dependency 'slack-notifier', '~> 1'
25
+ s.add_runtime_dependency 'quandl-slack'
26
26
 
27
- s.add_development_dependency "rspec", "~> 2.13"
28
- s.add_development_dependency "fivemat", "~> 1.2"
29
- s.add_development_dependency "pry"
30
- s.add_development_dependency "simplecov"
31
- s.add_development_dependency "guard"
32
- s.add_development_dependency "guard-rspec"
33
- end
27
+ s.add_development_dependency 'rspec', '~> 2.13'
28
+ s.add_development_dependency 'fivemat', '~> 1.2'
29
+ s.add_development_dependency 'pry'
30
+ s.add_development_dependency 'simplecov'
31
+ s.add_development_dependency 'guard'
32
+ s.add_development_dependency 'guard-rspec'
33
+ end
@@ -1,8 +1,8 @@
1
- $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
1
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w(.. lib))
2
2
 
3
- require "rspec"
3
+ require 'rspec'
4
4
  require 'pry'
5
5
 
6
6
  RSpec.configure do |config|
7
7
  config.include FactoryGirl::Syntax::Methods
8
- end
8
+ end
@@ -1,4 +1,4 @@
1
1
  inherit_from: <%= @base_directory %>/.rubocop.yml
2
2
 
3
- # Genereated automatically by Quandl::Utility at <%= Time.now %>
4
- # Project specific rules go here...
3
+ # Generated automatically by Quandl::Utility at <%= Time.now %>
4
+ # Project specific rules go here...
@@ -1,98 +1,97 @@
1
1
  gemc = Quandl::Utility::Tasks.configuration
2
2
 
3
- task :console do |t, args|
3
+ task :console do |_t, _args|
4
4
  require 'pry'
5
5
  binding.pry
6
6
  end
7
7
 
8
8
  namespace gemc.name do
9
-
9
+
10
10
  desc "Tag #{gemc.name} with #{gemc.version_with_prefix}"
11
11
  task :tag do
12
- raise "Must be a git repo." if %x{git status 2>&1} =~ /Not a git repository/
12
+ fail 'Must be a git repo.' if `git status 2>&1` =~ /Not a git repository/
13
13
  version = "#{gemc.tag_prefix}#{File.read('VERSION')}"
14
14
  system("git tag -a #{version} -m 'Release #{version}'")
15
- system("git push --tags")
15
+ system('git push --tags')
16
16
  end
17
-
17
+
18
18
  namespace :bump do
19
-
19
+
20
20
  desc "Perform major bump to #{gemc.name}"
21
21
  task :major do
22
- Rake::Task['quandl:bump:perform'].execute( severity: 'major' )
22
+ Rake::Task['quandl:bump:perform'].execute(severity: 'major')
23
23
  end
24
24
  desc "Perform minor bump to #{gemc.name}"
25
25
  task :minor do
26
- Rake::Task['quandl:bump:perform'].execute( severity: 'minor' )
26
+ Rake::Task['quandl:bump:perform'].execute(severity: 'minor')
27
27
  end
28
28
  desc "Perform patch bump to #{gemc.name}"
29
29
  task :patch do
30
- Rake::Task['quandl:bump:perform'].execute( severity: 'patch' )
30
+ Rake::Task['quandl:bump:perform'].execute(severity: 'patch')
31
31
  end
32
-
32
+
33
33
  end
34
-
34
+
35
35
  end
36
36
 
37
- namespace :quandl do
38
-
37
+ namespace :quandl do
38
+
39
39
  namespace :bump do
40
40
 
41
- task :perform, :severity do |t, args|
41
+ task :perform, :severity do |_t, args|
42
42
  # update changelog
43
- raise "Must be a git repo." if %x{git status 2>&1} =~ /Not a git repository/
44
- raise "You have unstaged commits." if %x{git status} =~ /Changes not staged for commit/
45
- Rake::Task['quandl:bump:version'].execute( severity: args[:severity] )
43
+ fail 'Must be a git repo.' if `git status 2>&1` =~ /Not a git repository/
44
+ fail 'You have unstaged commits.' if `git status` =~ /Changes not staged for commit/
45
+ Rake::Task['quandl:bump:version'].execute(severity: args[:severity])
46
46
  Rake::Task['quandl:changelog:update'].execute
47
47
  end
48
-
49
- task :version, :severity do |t, args|
48
+
49
+ task :version, :severity do |_t, args|
50
50
  severity = args[:severity]
51
51
  # extract version info
52
- major, minor, patch = gemc.version.split(".")
52
+ major, minor, patch = gemc.version.split('.')
53
53
  # bump
54
54
  case severity.to_sym
55
- when :major then
55
+ when :major then
56
56
  major = major.to_i + 1
57
57
  minor = 0
58
58
  patch = 0
59
-
60
- when :minor then
59
+
60
+ when :minor then
61
61
  minor = minor.to_i + 1
62
62
  patch = 0
63
-
64
- when :patch then
63
+
64
+ when :patch then
65
65
  patch = patch.to_i + 1
66
66
  end
67
67
  # commit
68
- new_version = [major, minor, patch].join(".")
69
- File.write( gemc.version_path, new_version )
68
+ new_version = [major, minor, patch].join('.')
69
+ File.write(gemc.version_path, new_version)
70
70
  system("git add #{gemc.version_path}; git commit -m 'Version bump to #{new_version}'")
71
71
  end
72
-
73
-
72
+
74
73
  end
75
-
74
+
76
75
  namespace :changelog do
77
- task :update do |t, args|
76
+ task :update do |_t, _args|
78
77
  # collect commits that match JIRA syntax
79
78
  since = gemc.version_with_prefix
80
- commits = gemc.changelog_matching.collect do |matching|
81
- %x{ git --no-pager log #{since}..HEAD --pretty=oneline --grep='#{matching}'}
79
+ commits = gemc.changelog_matching.map do |matching|
80
+ ` git --no-pager log #{since}..HEAD --pretty=oneline --grep='#{matching}'`
82
81
  end.join
83
82
  # split newlines and exclude reference, select uniq
84
- commits = commits.split("\n").collect{|c| "* #{c[41..-1]}" }.uniq
83
+ commits = commits.split("\n").map { |c| "* #{c[41..-1]}" }.uniq
85
84
  # compose prepend string
86
85
  new_version = File.read('VERSION')
87
86
  commits = "## #{new_version} \n\n" + commits.join("\n") + "\n\n\n\n"
88
87
  # prepend to UPGRADE.md
89
88
  changelog = gemc.changelog_path
90
- puts "Appending commits matching #{gemc.changelog_matching.join(" ")} to #{changelog}\n#{commits}"
89
+ puts "Appending commits matching #{gemc.changelog_matching.join(' ')} to #{changelog}\n#{commits}"
91
90
  # check for existing changes
92
- existing_changes = File.exists?(changelog) ? File.read( changelog ) : ''
93
- File.write( changelog, commits + existing_changes )
91
+ existing_changes = File.exist?(changelog) ? File.read(changelog) : ''
92
+ File.write(changelog, commits + existing_changes)
94
93
  system("git add #{changelog}; git commit -m 'Updated changelog with commits from #{new_version}'")
95
94
  end
96
95
  end
97
-
98
- end
96
+
97
+ end
metadata CHANGED
@@ -1,14 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quandl_utility
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Hilscher
8
+ - Jason Byck
9
+ - Najwa Azer
8
10
  autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
- date: 2014-12-05 00:00:00.000000000 Z
13
+ date: 2014-12-19 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
16
  name: activesupport
@@ -81,19 +83,19 @@ dependencies:
81
83
  - !ruby/object:Gem::Version
82
84
  version: '0'
83
85
  - !ruby/object:Gem::Dependency
84
- name: slack-notifier
86
+ name: quandl-slack
85
87
  requirement: !ruby/object:Gem::Requirement
86
88
  requirements:
87
- - - "~>"
89
+ - - ">="
88
90
  - !ruby/object:Gem::Version
89
- version: '1'
91
+ version: '0'
90
92
  type: :runtime
91
93
  prerelease: false
92
94
  version_requirements: !ruby/object:Gem::Requirement
93
95
  requirements:
94
- - - "~>"
96
+ - - ">="
95
97
  - !ruby/object:Gem::Version
96
- version: '1'
98
+ version: '0'
97
99
  - !ruby/object:Gem::Dependency
98
100
  name: rspec
99
101
  requirement: !ruby/object:Gem::Requirement
@@ -204,7 +206,6 @@ files:
204
206
  - lib/quandl/utility/thor_tasks.rb
205
207
  - lib/quandl/utility/thor_tasks/ci.rb
206
208
  - lib/quandl/utility/thor_tasks/lint.rb
207
- - lib/quandl/utility/thor_tasks/notify.rb
208
209
  - lib/quandl/utility/version.rb
209
210
  - quandl_utility.gemspec
210
211
  - spec/spec_helper.rb
@@ -1,35 +0,0 @@
1
- require 'slack-notifier'
2
-
3
- module Quandl
4
- module Utility
5
- module ThorTasks
6
- # Tasks for sending notifications
7
- class Notify < Thor
8
- namespace 'qutil:notify'
9
-
10
- method_option :emoji,
11
- type: :string,
12
- aliases: '-e',
13
- required: false,
14
- banner: 'EMOJI'
15
- method_option :webhook,
16
- type: :string,
17
- aliases: '-w',
18
- required: true,
19
- default: ENV['SLACK_WEBHOOK'],
20
- banner: 'WEBHOOK'
21
- method_option :botname,
22
- type: :string,
23
- aliases: '-b',
24
- required: false,
25
- default: ENV['SLACK_BOTNAME'],
26
- banner: 'BOTNAME'
27
- desc 'slack message channel', 'Send notification to slack'
28
- def slack(message, channel)
29
- slack_client = Slack::Notifier.new(options[:webhook], channel: channel, username: options[:botname])
30
- slack_client.ping(message, icon_emoji: options[:emoji])
31
- end
32
- end
33
- end
34
- end
35
- end